<?php

class ectools_finder_currency extends desktop_controller {

    var $detail_currency = '货币信息';

    public function __construct($app) {
        $this->app = $app;
    }

    public function detail_currency($id) {
        $currency = $this->app->model('currency');
        
        if ($_POST) {
            $this->begin("index.php?app=ectools&ctl=currency&act=index");
            $_POST['cur_id'] = $id;
            if (isset($_POST['cur_default']) && $_POST['cur_default'] == 'true')
                $currency->set_currency_default();
            $result = $currency->save($_POST);
            $this->end($result, app::get('ectools')->_('货币修改成功！'));
        } else {
            
            $render = $this->app->render();
            $cur = $currency->dump($id);
            $render->pagedata['curs_name'] = $cur['cur_sign'] . ' ' . $cur['cur_name'];
            ;
            $render->pagedata['cur_id'] = $id;
            $render->pagedata['cur_code'] = $cur['cur_code'];
            $render->pagedata['cur_name'] = $cur['cur_name'];
            $render->pagedata['cur_sign'] = $cur['cur_sign'];
            $render->pagedata['cur_rate'] = $cur['cur_rate'];
            $render->pagedata['cur_default'] = $cur['cur_default'];
            
            return $render->fetch('currency/view_cur.html');
        }
    }

    public $column_editbutton = '编辑';

    public function column_editbutton($row) {
        return '<a href="index.php?app=ectools&ctl=currency&act=showEdit&cur_id=' . $row['cur_id'] . '&_finder[finder_id]=' . $_GET['_finder']['finder_id'] . '&finder_id=' . $_GET['_finder']['finder_id'] . '" target="dialog::{title:\'' . app::get('ectools')->_('编辑货币信息') . '\',width:700,height:300}"><span>' . app::get('ectools')->_('编辑') . '</span></a>';
    }
}
